//
//  FootballDetailViewController.m
//  B
//
//  Created by lanou on 16/5/11.
//  Copyright © 2016年 裴启航. All rights reserved.
//

#import "FootballDetailViewController.h"
#import "SVProgressHUD.h"
#import "UIView+QHExtension.h"
@interface FootballDetailViewController ()<UIWebViewDelegate>
{
    CGFloat lastX;
    CGFloat lastY;
}

@property (nonatomic, strong) UIWebView *webView;

@end

@implementation FootballDetailViewController
-(void)viewWillAppear:(BOOL)animated
{
    [SVProgressHUD showWithStatus:@"waiting"];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.tabBarController.tabBar.hidden = YES;
    self.view.backgroundColor = [UIColor cyanColor];
    NSLog(@"%@", _getUrl1);
    
    
    self.webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight)];
    // 手势
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panAction:)];
    [self.webView addGestureRecognizer:pan];
    
    self.webView.delegate = self;
    NSURL *url = [NSURL URLWithString:_getUrl1];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:request];
    
    [self.view addSubview:self.webView];
}

#pragma mark - 手势方法
-(void)panAction:(UIPanGestureRecognizer *)pan
{
    CGPoint currentPoint = [pan translationInView:self.webView];
    self.webView.transform = CGAffineTransformTranslate(self.webView.transform, currentPoint.x - lastX, currentPoint.y - lastY);
    lastX = currentPoint.x;
    lastY = currentPoint.y;
    // 判断手指离开的时候，指控x,y 防止webView回到原位
    if (pan.state == UIGestureRecognizerStateEnded) {
        lastX = 0;
        lastY = 0;
    }
}

-(void)viewWillDisappear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = NO;
}

-(void)viewDidAppear:(BOOL)animated
{
    [SVProgressHUD dismiss];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
